package com.linkage.lcims.base.dao.cdma.impl;

import java.util.List;
import java.util.Map;

import com.linkage.lcims.base.dao.HibernateBaseDAOImpl;
import com.linkage.lcims.base.dao.cdma.interfaces.ImsiSegmentDAO;
import com.linkage.lcims.base.po.cdma.CImsiSegment;
import com.linkage.util.exception.DAOException;

public class ImsiSegmentDAOImpl extends HibernateBaseDAOImpl implements ImsiSegmentDAO {

	@SuppressWarnings("unchecked")
	public List<CImsiSegment> getAll() throws DAOException {
		return this.getAll(CImsiSegment.class);
	}
	
	public void deleteImsiSegment(CImsiSegment imsiSegment)
			throws DAOException {
		this.delete(imsiSegment);
	}

	public CImsiSegment getImsiSegment(
			String startimsi) throws DAOException {
		return (CImsiSegment)this.getByID(CImsiSegment.class, startimsi);
	}

	public void saveImsiSegment(CImsiSegment imsiSegment)
			throws DAOException {
		this.save(imsiSegment);
	}

	public void updateImsiSegment(CImsiSegment imsiSegment)
			throws DAOException {
		this.merge(imsiSegment);
	}

	public void updateImsiSegmentFileds(String startimsi, Map<String, ?> fileds)
			throws DAOException {
		super.updateField(CImsiSegment.class.getName(), startimsi, fileds);		
	}

	@SuppressWarnings("unchecked")
	public List<CImsiSegment> getImsiSegmentsButSelf(CImsiSegment imsiSegment)throws DAOException {
		String hql="from CImsiSegment where startimsi !='"+imsiSegment.getStartimsi()
		+"' and stopimsi != '"+imsiSegment.getStopimsi()+"'";
		return this.query(hql);
	}
}
